﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
/*
 * 20/08/2008
 * 
 * Part of the open source project mbrPropertyGrid
 * Developer : mbr ® (Massimiliano Brugnerotto)
 *  
 */
namespace mbrPropertyGrid
{
    partial class FrmAboutMe : Form
    {

        #region Private internal var./properties

        private string mInfoMessage = "A commercial version of this control, with several additional functions, will be available soon at http://www.palladiosoftware.com";

        #endregion

        /// <summary>
        /// Form constructor.
        /// </summary>
        public FrmAboutMe()
        {
            InitializeComponent();
            // Show assembly info.
            this.Text = "About " + AssemblyTitle + " User Control";
            this.labelProductName.Text = "Product name : " + AssemblyProduct;
            this.labelVersion.Text = "Version : " + AssemblyVersion;
            this.labelCopyright.Text = "Copyright : " + AssemblyCopyright;
            this.labelCompanyName.Text = "Company : " + AssemblyCompany;
            this.textBoxDescription.Text = AssemblyDescription;
        }

        #region Assembly Attribute Accessors (public read-only properties)

        public string AssemblyTitle
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
                if (attributes.Length > 0)
                {
                    AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
                    if (titleAttribute.Title != "")
                    {
                        return titleAttribute.Title;
                    }
                }
                return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
            }
        }

        public string AssemblyVersion
        {
            get
            {
                return Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
        }

        public string AssemblyDescription
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyDescriptionAttribute)attributes[0]).Description + "\r\n" + mInfoMessage;
            }
        }

        public string AssemblyProduct
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyProductAttribute)attributes[0]).Product;
            }
        }

        public string AssemblyCopyright
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
            }
        }

        public string AssemblyCompany
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
                if (attributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyCompanyAttribute)attributes[0]).Company;
            }
        }
        #endregion

        #region Public properties

        /// <summary>
        /// Gets/sets an addition message string to show on the screen.
        /// </summary>
        public string InfoMessage
        {
            get
            {
                return mInfoMessage;
            }
            set
            {
                mInfoMessage = value;
                this.textBoxDescription.Text = AssemblyDescription;
            }
        }

        #endregion

        #region Events generated by user interface

        private void okButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        #endregion

    }
}
